package com.qf.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

public class EsClient {
//    获取连接

    public static RestHighLevelClient getClient() {
//      创建 httphost 对象 获取 地址集端口
        HttpHost httpHost = new HttpHost("10.9.45.217", 9200, "http");
//       创建RestClientBuilder   客户端拿到了IP 地址
        RestClientBuilder builder = RestClient.builder(httpHost);
//      建立连接了
        RestHighLevelClient highLevelClient = new RestHighLevelClient(builder);
//      返回连接对象
        return highLevelClient;


    }

}
